import java.util.Arrays;

public class test2 {
    //力扣 611 有效三角形的个数
    public static void main(String[] args) {
        int[] nums = {4,2,3,4};

        Arrays.sort(nums);
        int max = nums.length-1;

        int count = 0;
        while (max>=2){
            int left = 0;
            int right = max-1;

            while (left<right){

                if(nums[left]+nums[right]>nums[max]){
                    count = count + right-left;
                    right--;
                }else{
                    left++;
                }

            }
            max--;
        }
        System.out.println(count);
    }
}
